﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace WMSWebApi.Models
{
    public partial class WMSDATAContext : DbContext
    {
        public WMSDATAContext()
        {
        }

        public WMSDATAContext(DbContextOptions<WMSDATAContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Header> Headers { get; set; }
        public virtual DbSet<MaterialsTable> MaterialsTables { get; set; }
        public virtual DbSet<StationsTable> StationsTables { get; set; }
        public virtual DbSet<TasksTable> TasksTables { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
          //#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Server=WIN-UMRSB78SIKM;database=WMSDATA;Trusted_Connection=True;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<Header>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("Header");

                entity.Property(e => e.AppSecret)
                    .HasMaxLength(50)
                    .HasColumnName("appSecret");

                entity.Property(e => e.AppSys)
                    .HasMaxLength(50)
                    .HasColumnName("appSys");

                entity.Property(e => e.RequestId)
                    .HasMaxLength(50)
                    .HasColumnName("requestId");

                entity.Property(e => e.Timestamp)
                    .HasPrecision(3)
                    .HasColumnName("timestamp");

                entity.Property(e => e.Version)
                    .HasMaxLength(50)
                    .HasColumnName("version");
            });

            modelBuilder.Entity<MaterialsTable>(entity =>
            {
                entity.ToTable("MaterialsTable");

                entity.Property(e => e.MaterialCode).HasMaxLength(50);

                entity.Property(e => e.MaterialName).HasMaxLength(50);
            });

            modelBuilder.Entity<StationsTable>(entity =>
            {
                entity.ToTable("StationsTable");

                entity.Property(e => e.StationName).HasMaxLength(50);

                entity.Property(e => e.StationStatus).HasMaxLength(50);
            });

            modelBuilder.Entity<TasksTable>(entity =>
            {
                entity.ToTable("TasksTable");

                entity.Property(e => e.EndTime).HasColumnType("datetime");

                entity.Property(e => e.MaterialName).HasMaxLength(50);

                entity.Property(e => e.StartTime).HasColumnType("datetime");

                entity.Property(e => e.TaskNumber).HasMaxLength(50);

                entity.Property(e => e.TaskStatus).HasMaxLength(50);

                entity.Property(e => e.TaskType).HasMaxLength(50);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
